package org.snaker.engine.springboot.configuration;

import org.snaker.engine.Expression;
import org.snaker.engine.interceptors.SnakerInterceptor;
import org.snaker.engine.parser.xml.node.CustomParser;
import org.snaker.engine.parser.xml.node.DecisionParser;
import org.snaker.engine.parser.xml.node.EndParser;
import org.snaker.engine.parser.xml.node.ForkParser;
import org.snaker.engine.parser.xml.node.JoinParser;
import org.snaker.engine.parser.xml.node.StartParser;
import org.snaker.engine.parser.xml.node.SubProcessParser;
import org.snaker.engine.parser.xml.node.TaskParser;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.List;

/**
 * 代替base.config.xml的初始化注入
 */
@Configuration
public class ParserConfiguration {

    @Bean
    public StartParser start(List<SnakerInterceptor> snakerInterceptors){
        return new StartParser(snakerInterceptors);
    }

    @Bean
    public Expression expression(){
        return new org.snaker.engine.impl.JuelExpression();
    }

    @Bean
    public TaskParser task(List<SnakerInterceptor> snakerInterceptors){
        return new TaskParser(snakerInterceptors);
    }

    @Bean
    public CustomParser custom(List<SnakerInterceptor> snakerInterceptors){
        return new CustomParser(snakerInterceptors);
    }

    @Bean
    public DecisionParser decision(Expression expression, List<SnakerInterceptor> snakerInterceptors){
        return new DecisionParser(expression, snakerInterceptors);
    }

    @Bean
    public SubProcessParser subprocess(List<SnakerInterceptor> snakerInterceptors){
        return new SubProcessParser(snakerInterceptors);
    }

    @Bean
    public ForkParser fork(List<SnakerInterceptor> snakerInterceptors){
        return new ForkParser(snakerInterceptors);
    }

    @Bean
    public JoinParser join(List<SnakerInterceptor> snakerInterceptors){
        return new JoinParser(snakerInterceptors);
    }

    @Bean
    public EndParser end(List<SnakerInterceptor> snakerInterceptors){
        return new EndParser(snakerInterceptors);
    }
}
